package com.amado.course45mysql02.controller;

import java.util.List;
import java.util.Scanner;

import com.amado.course45mysql02.domain.Page;
import com.amado.course45mysql02.domain.Student;
import com.amado.course45mysql02.service.StudentService;
import com.amado.course45mysql02.service.impl.StudentServiceImpl;

public class StudentController {
	private static Scanner scanner = new Scanner(System.in);
	private StudentService studentService = new StudentServiceImpl();
	public static void main(String[] args) {
		StudentController controller = new StudentController();
		while(true) {
			System.out.println("1 添加2删除3修改 4查询5分页查询");
			int menu = scanner.nextInt();
			if(menu==5) {
				controller.page();
			}
		}
		
	}
	public void page() {
		System.out.println("请输入你要查询的页码");
		int pageNumber = scanner.nextInt();
		Page<Student> page = studentService.page(pageNumber, 3);
		List<Student> studentList = page.getData();
		System.out.println("一共多少条数据"+page.getCount());
		System.out.println("一共多少页"+page.getTotalPage());
		System.out.println("ID,姓名。。年龄 ");
		studentList.forEach(e->System.out.println(e));
	}
	
}
